<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class home extends CI_Controller {
	  var $data = array();

	  public function __construct() {
        parent::__construct();
        if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
        $this->data['sidebarhome']="";
	    $this->data['sidebardaftar']="";
	    $this->data['sidebardaftarclient']="";
	    $this->data['sidebardaftarfinance']="";
    	$this->data['sidebarinputdata']="";
    	
    	$this->data['sidebarcustomer']="";
    	$this->data['sidebarcabang']="";
    	$this->data['sidebaruser']="";

    	$this->load->model('mkaryawan');

       }

    public function index() {
      /*if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
       $data['list'] = $this->mvendor->dasboardallvendor();*/
       $this->load->helper('url');
       $this->data['sidebarhome']="active";
       $this->load->view('vhome',$this->data);

       
        //$this->load->view('vchart');
    }
    public function inputdata() {
      /*if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
       $data['list'] = $this->mvendor->dasboardallvendor();*/
       $this->load->helper('url');
       $this->data['sidebarinputdata']="active";
       $this->data['queryprovinsi'] = $this->mkaryawan->fgetallprovinsi();
       $this->data['querykota'] = $this->mkaryawan->fgetallkota();
       $this->data['querycustomer'] = $this->mkaryawan->fgetallcustomer();
       $this->load->view('vinputdata',$this->data);

       
        //$this->load->view('vchart');
    }
    public function listdata() {
      /*if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
       $data['list'] = $this->mvendor->dasboardallvendor();*/
       $this->load->helper('url');
       $this->data['sidebardaftar']="active";
       
       //cek role
       $queryuser = $this->muser->get_user($this->session->userdata('username'));
       $id_provinsi = $queryuser->id_provinsi;
       $id_kota = $queryuser->id_kota;
       $id_customer = $queryuser->id_customer;
       $this->data['ctr_provinsi'] = '';
       $this->data['ctr_cabang'] = '';
       $this->data['ctr_customer'] = '';
       if($this->session->userdata('role') == '2') 
       {
       		$this->data['ctr_provinsi'] = 'disabled';
       		$this->data['ctr_cabang'] = 'disabled';
       		if ($this->uri->segment(3) != $id_kota)
       		{
       			$provinsi = $this->mkaryawan->get_provinsi($id_kota);
       			if($this->uri->segment(4) != '')
					redirect('home/listdata/'.$id_kota.'/'.$this->uri->segment(4).'/'.$provinsi); 
				else
					redirect('home/listdata/'.$id_kota.'/0/'.$provinsi); 
       		}
       }
       elseif($this->session->userdata('role') == '4') 
       {
       		$this->data['ctr_provinsi'] = 'disabled';
       		if ($this->uri->segment(5) != $id_provinsi)
       		{
       			if($this->uri->segment(3) !='' && $this->uri->segment(4) != '')
					redirect('home/listdata/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$id_provinsi); 
    			elseif ($this->uri->segment(3) !='')
    				redirect('home/listdata/'.$this->uri->segment(3).'/0/'.$id_provinsi); 
    			else
    				redirect('home/listdata/0/0/'.$id_provinsi); 
       		}
       }
       elseif($this->session->userdata('role') == '5')
       {
       		$this->data['ctr_customer'] = 'disabled';
       		if($this->uri->segment(4) != $id_customer)
       		{
	       		if($this->uri->segment(3) == '')
					redirect('home/listdataclient/0/'.$id_customer); 
				else
					redirect('home/listdataclient/'.$this->uri->segment(3).'/'.$id_customer); 
			}
	   }
       //cek filter
       if($this->uri->segment(3) != '' || $this->uri->segment(4) != '' || $this->uri->segment(5) != '')
       {
       		if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 || $this->session->userdata('role') == 5  )
						$this->data['query'] = $this->mkaryawan->getdatakaryawanfilter($this->uri->segment(3),$this->uri->segment(4),$this->uri->segment(5));
					else
						$this->data['query'] = $this->mkaryawan->getdatakaryawanfilter_user($this->uri->segment(3),$this->uri->segment(4),$this->uri->segment(5),$this->session->userdata('username'));
       }
       else{
       		if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 || $this->session->userdata('role') == 5  )
	       		$this->data['query'] = $this->mkaryawan->getallkaryawan();
    		else
    			$this->data['query'] = $this->mkaryawan->getallkaryawan_user($this->session->userdata('username'));
       }
       $this->data['queryprovinsi'] = $this->mkaryawan->fgetallprovinsi();
       $this->data['querykota'] = $this->mkaryawan->fgetallkota();
       $this->data['querycustomer'] = $this->mkaryawan->fgetallcustomer();
       $this->data['queryalluser'] = $this->mkaryawan->getalluser();
       $this->load->view('vlistdata',$this->data);

       
        //$this->load->view('vchart');
    }     
    public function listdataresign() {
      /*if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
       $data['list'] = $this->mvendor->dasboardallvendor();*/
       $this->load->helper('url');
       $this->data['sidebardaftar']="active";
       
       //cek role
       $queryuser = $this->muser->get_user($this->session->userdata('username'));
       $id_provinsi = $queryuser->id_provinsi;
       $id_kota = $queryuser->id_kota;
       $id_customer = $queryuser->id_customer;
       $this->data['ctr_provinsi'] = '';
       $this->data['ctr_cabang'] = '';
       $this->data['ctr_customer'] = '';
       if($this->session->userdata('role') == '2') 
       {
       		$this->data['ctr_provinsi'] = 'disabled';
       		$this->data['ctr_cabang'] = 'disabled';
       		if ($this->uri->segment(3) != $id_kota)
       		{
       			$provinsi = $this->mkaryawan->get_provinsi($id_kota);
       			if($this->uri->segment(4) != '')
					redirect('home/listdataresign/'.$id_kota.'/'.$this->uri->segment(4).'/'.$provinsi); 
				else
					redirect('home/listdataresign/'.$id_kota.'/0/'.$provinsi); 
       		}
       }
       elseif($this->session->userdata('role') == '4') 
       {
       		$this->data['ctr_provinsi'] = 'disabled';
       		if ($this->uri->segment(5) != $id_provinsi)
       		{
       			if($this->uri->segment(3) !='' && $this->uri->segment(4) != '')
					redirect('home/listdataresign/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$id_provinsi); 
    			elseif ($this->uri->segment(3) !='')
    				redirect('home/listdataresign/'.$this->uri->segment(3).'/0/'.$id_provinsi); 
    			else
    				redirect('home/listdataresign/0/0/'.$id_provinsi); 
       		}
       }
       elseif($this->session->userdata('role') == '5')
       {
       		$this->data['ctr_customer'] = 'disabled';
       		if($this->uri->segment(4) != $id_customer)
       		{
	       		if($this->uri->segment(3) == '')
					redirect('home/listdataresign/0/'.$id_customer); 
				else
					redirect('home/listdataresign/'.$this->uri->segment(3).'/'.$id_customer); 
			}
	   }
       //cek filter
       if($this->uri->segment(3) != '' || $this->uri->segment(4) != '' || $this->uri->segment(5) != '')
       {
       		if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 || $this->session->userdata('role') == 5  )
						$this->data['query'] = $this->mkaryawan->getdatakaryawanresignfilter($this->uri->segment(3),$this->uri->segment(4),$this->uri->segment(5));
					else
						$this->data['query'] = $this->mkaryawan->getdatakaryawanresignfilter_user($this->uri->segment(3),$this->uri->segment(4),$this->uri->segment(5),$this->session->userdata('username'));
       }
       	else{
       		if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 || $this->session->userdata('role') == 5  )
       			$this->data['query'] = $this->mkaryawan->getkaryawanresign();
       		else
       			$this->data['query'] = $this->mkaryawan->getkaryawanresign_user($this->session->userdata('username'));
       	}
       	$this->data['queryprovinsi'] = $this->mkaryawan->fgetallprovinsi();
       	$this->data['querykota'] = $this->mkaryawan->fgetallkota();
       	$this->data['querycustomer'] = $this->mkaryawan->fgetallcustomer();
       	$this->load->view('vlistdata_resign',$this->data);

       
        //$this->load->view('vchart');
    }     
    public function listdataclient() {
      /*if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
       $data['list'] = $this->mvendor->dasboardallvendor();*/
       $this->load->helper('url');
       $this->data['sidebardaftarclient']="active";
       //$this->data['query'] = $this->mkaryawan->getallkaryawan();
       //cek role
       $queryuser = $this->muser->get_user($this->session->userdata('username'));
       $id_kota = $queryuser->id_kota;
       $id_provinsi = $queryuser->id_provinsi;
       $id_customer = $queryuser->id_customer;
       $this->data['ctr_provinsi'] = '';
       $this->data['ctr_cabang'] = '';
       $this->data['ctr_customer'] = '';
       if($this->session->userdata('role') == '2') 
       {
       		$this->data['ctr_provinsi'] = 'disabled';
       		$this->data['ctr_cabang'] = 'disabled';
       		if ($this->uri->segment(3) != $id_kota)
				redirect('home/listdataclient/'.$id_kota.'/'.$this->uri->segment(4)); 
       }
       elseif($this->session->userdata('role') == '4') 
       {
       		$this->data['ctr_provinsi'] = 'disabled';
       		if ($this->uri->segment(5) != $id_provinsi)
       		{
       			if($this->uri->segment(3) !='' && $this->uri->segment(4) != '')
					redirect('home/listdataclient/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$id_provinsi); 
    			elseif ($this->uri->segment(3) !='')
    				redirect('home/listdataclient/'.$this->uri->segment(3).'/0/'.$id_provinsi); 
    			else
    				redirect('home/listdataclient/0/0/'.$id_provinsi); 
       		}
       }
       elseif($this->session->userdata('role') == '5')
       {
       		$this->data['ctr_customer'] = 'disabled';
       		if($this->uri->segment(4) != $id_customer)
       		{
	       		if($this->uri->segment(3) == '')
					redirect('home/listdataclient/0/'.$id_customer); 
				else
					redirect('home/listdataclient/'.$this->uri->segment(3).'/'.$id_customer); 
			}
	   }       
	   //cek filter
       if($this->uri->segment(3) != '' || $this->uri->segment(4) != '' || $this->uri->segment(5) != '')
       {
       		if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 || $this->session->userdata('role') == 5  )
	       		$this->data['query'] = $this->mkaryawan->getdatakaryawanfilter($this->uri->segment(3),$this->uri->segment(4),$this->uri->segment(5));
					else
						$this->data['query'] = $this->mkaryawan->getdatakaryawanfilter_user($this->uri->segment(3),$this->uri->segment(4),$this->uri->segment(5),$this->session->userdata('username'));
       }
       else{
       		if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 || $this->session->userdata('role') == 5  )
	       		$this->data['query'] = $this->mkaryawan->getallkaryawan();
    			else
    				$this->data['query'] = $this->mkaryawan->getallkaryawan_user($this->session->userdata('username'));
       }
       $this->data['queryprovinsi'] = $this->mkaryawan->fgetallprovinsi();
       $this->data['querykota'] = $this->mkaryawan->fgetallkota();
       $this->data['querycustomer'] = $this->mkaryawan->fgetallcustomer();
       $this->load->view('vlistdata_client',$this->data);

       
        //$this->load->view('vchart');
    }     

    public function listdatafinance() {
      /*if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
       $data['list'] = $this->mvendor->dasboardallvendor();*/
       $this->load->helper('url');
       $this->data['sidebardaftarfinance']="active";
       //cek role
       $queryuser = $this->muser->get_user($this->session->userdata('username'));
       $id_provinsi = $queryuser->id_provinsi;
       $id_kota = $queryuser->id_kota;
       $id_customer = $queryuser->id_customer;
       $this->data['ctr_provinsi'] = '';
       $this->data['ctr_cabang'] = '';
       $this->data['ctr_customer'] = '';
       if($this->session->userdata('role') == '2') 
       {
       		$this->data['ctr_provinsi'] = 'disabled';
       		$this->data['ctr_cabang'] = 'disabled';
       		if ($this->uri->segment(3) != $id_kota)
				redirect('home/listdatafinance/'.$id_kota.'/'.$this->uri->segment(4)); 
       }
       elseif($this->session->userdata('role') == '4') 
       {
       		$this->data['ctr_provinsi'] = 'disabled';
       		if ($this->uri->segment(5) != $id_provinsi)
       		{
       			if($this->uri->segment(3) !='' && $this->uri->segment(4) != '')
					redirect('home/listdatafinance/'.$this->uri->segment(3).'/'.$this->uri->segment(4).'/'.$id_provinsi); 
    			elseif ($this->uri->segment(3) !='')
    				redirect('home/listdatafinance/'.$this->uri->segment(3).'/0/'.$id_provinsi); 
    			else
    				redirect('home/listdatafinance/0/0/'.$id_provinsi); 
       		}
       }
       elseif($this->session->userdata('role') == '5')
       {
       		$this->data['ctr_customer'] = 'disabled';
       		if($this->uri->segment(4) != $id_customer)
       		{
	       		if($this->uri->segment(3) == '')
					redirect('home/listdatafinance/0/'.$id_customer); 
				else
					redirect('home/listdatafinance/'.$this->uri->segment(3).'/'.$id_customer); 
			}
	   }       
	   //cek filter
       if($this->uri->segment(3) != '' || $this->uri->segment(4) != '' || $this->uri->segment(5) != '')
       {
       		if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 || $this->session->userdata('role') == 5  )
       			$this->data['query'] = $this->mkaryawan->getdatakaryawanfilter($this->uri->segment(3),$this->uri->segment(4),$this->uri->segment(5));
					else
						$this->data['query'] = $this->mkaryawan->getdatakaryawanfilter_user($this->uri->segment(3),$this->uri->segment(4),$this->uri->segment(5),$this->session->userdata('username'));
       }
       else{
       		if($this->session->userdata('role') == 1 || $this->session->userdata('role') == 3 || $this->session->userdata('role') == 5  )
	       		$this->data['query'] = $this->mkaryawan->getallkaryawan();
    			else
    				$this->data['query'] = $this->mkaryawan->getallkaryawan_user($this->session->userdata('username'));
       }
       $this->data['queryprovinsi'] = $this->mkaryawan->fgetallprovinsi();
       $this->data['querykota'] = $this->mkaryawan->fgetallkota();
       $this->data['querycustomer'] = $this->mkaryawan->fgetallcustomer();
       $this->load->view('vlistdata_finance',$this->data);

       
        //$this->load->view('vchart');
    }     

 	function fPSaveData()
	{

  		if($this->input->post('customer') == '')
	  		$id_customer = $this->session->userdata('id_customer');
	  	else
	  		$id_customer = $this->input->post('customer');
	  		
  		if($this->input->post('cabang') == '')
	  		$id_cabang = $this->session->userdata('id_kota');
	  	else
	  		$id_cabang = $this->input->post('cabang');

        $data123 = array(
			'id' => $this->input->post('id'),
			'username_creator' => $this->session->userdata('username'),
			'tanggal_update' => date('Y-m-d', strtotime(getdate())),
			'id_customer' => $id_customer,
			'nik_customer' => $this->input->post('nik_customer'),
			'nik_sjs' => $this->input->post('nik_sjs'),
			'nama_kar' => $this->input->post('nama_kar'),
			'jabatan' => $this->input->post('jabatan'),
			'departement' => $this->input->post('departement'),
			'id_cabang' => $id_cabang,
			'status_kar' => $this->input->post('status_kar'),			
			'joint_awal' => date('Y-m-d', strtotime($this->input->post('joint_awal'))),
			'total_cuti' => $this->input->post('total_cuti'),
			'cuti_dipakai' => $this->input->post('cuti_dipakai'),
			'sisa_cuti' => $this->input->post('sisa_cuti'),
			'bank' => $this->input->post('bank'),
			'no_rekening' => $this->input->post('no_rekening'),
			'nama_rek' => $this->input->post('nama_rek'),
			'jenis_kelamin' => $this->input->post('jenis_kelamin'),
			'tempat_lahir' => $this->input->post('tempat_lahir'),
			'tanggal_lahir' => date('Y-m-d', strtotime($this->input->post('tanggal_lahir'))),
			'agama' => $this->input->post('agama'),
			'alamat_ktp' => $this->input->post('alamat_ktp'),
			'rt' => $this->input->post('rt'),
			'rw' => $this->input->post('rw'),
			'kode_pos' => $this->input->post('kode_pos'),
			'kecamatan' => $this->input->post('kecamatan'),
			'desa' => $this->input->post('desa'),
			'kabupaten' => $this->input->post('kabupaten'),
			'alamat_tinggal' => $this->input->post('alamat_tinggal'),
			'rt_tinggal' => $this->input->post('rt_tinggal'),
			'rw_tinggal' => $this->input->post('rw_tinggal'),
			'kode_pos_tinggal' => $this->input->post('kode_pos_tinggal'),
			'kecamatan_tinggal' => $this->input->post('kecamatan_tinggal'),
			'desa_tinggal' => $this->input->post('desa_tinggal'),
			'kabupaten_tinggal' => $this->input->post('kabupaten_tinggal'),
			'tel_rumah' => $this->input->post('tel_rumah'),
			'tel_hp' => $this->input->post('tel_hp'),
			'tel_hp2' => $this->input->post('tel_hp2'),
			'tel_keluarga' => $this->input->post('tel_keluarga'),
			'hub_keluarga' => $this->input->post('hub_keluarga'),
			'nama_keluarga' => $this->input->post('nama_keluarga'),
			'pendidikan' => $this->input->post('pendidikan'),
			'nama_sekolah' => $this->input->post('nama_sekolah'),
			'jurusan' => $this->input->post('jurusan'),
			'jenis_identitas' => $this->input->post('jenis_identitas'),
			'no_identitas' => $this->input->post('no_identitas'),
			'no_npwp' => $this->input->post('no_npwp'),
			'no_jamsostek' => $this->input->post('no_jamsostek'),
			'bpjs' => $this->input->post('bpjs'),
			'nama_asuransi' => $this->input->post('nama_asuransi'),
			'no_asuransi' => $this->input->post('no_asuransi'),
			'kode_jamsostek' => $this->input->post('kode_jamsostek'),
			'ppk_jamsostek' => $this->input->post('ppk_jamsostek'),
			'tipe_jaminan' => $this->input->post('tipe_jaminan'),
			'no_jaminan' => $this->input->post('no_jaminan'),
			'no_bpkb' => $this->input->post('no_bpkb'),
			'penyimpanan_jaminan' => $this->input->post('penyimpanan_jaminan'),
			'nama_ibu' => $this->input->post('nama_ibu'),
			'status_perkawinan' => $this->input->post('status_perkawinan'),
			'no_kk' => $this->input->post('no_kk'),
			'nama_suami_istri' => $this->input->post('nama_suami_istri'),
			'no_ktp_nik_pasangan' => $this->input->post('no_ktp_nik_pasangan'),
			'jenis_kelamin_si' => $this->input->post('jenis_kelamin_si'),
			'tempat_lahir_si' => $this->input->post('tempat_lahir_si'),
			'tgl_lahir_si' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_si'))),
			'nama_anak1' => $this->input->post('nama_anak1'),
			'jenis_kelamin_anak1' => $this->input->post('jenis_kelamin_anak1'),
			'tempat_lahir_anak1' => $this->input->post('tempat_lahir_anak1'),
			'tgl_lahir_anak1' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_anak1'))),
			'nama_anak2' => $this->input->post('nama_anak2'),
			'jenis_kelamin_anak2' => $this->input->post('jenis_kelamin_anak2'),
			'tempat_lahir_anak2' => $this->input->post('tempat_lahir_anak2'),
			'tgl_lahir_anak2' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_anak2'))),
			'nama_anak3' => $this->input->post('nama_anak3'),
			'jenis_kelamin_anak3' => $this->input->post('jenis_kelamin_anak3'),
			'tempat_lahir_anak3' => $this->input->post('tempat_lahir_anak3'),
			'tgl_lahir_anak3' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_anak3'))),
			'nama_anak4' => $this->input->post('nama_anak4'),
			'jenis_kelamin_anak4' => $this->input->post('jenis_kelamin_anak4'),
			'tempat_lahir_anak4' => $this->input->post('tempat_lahir_anak4'),
			'tgl_lahir_anak4' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_anak4'))),
			'no_pkwt1' => $this->input->post('no_pkwt1'),
			'awal_kontrak_pkwt1' => date('Y-m-d', strtotime($this->input->post('awal_kontrak_pkwt1'))),
			'akhir_kontrak_pkwt1' => date('Y-m-d', strtotime($this->input->post('akhir_kontrak_pkwt1'))),
			'lama_kontrak1' => $this->input->post('lama_kontrak1'),
			'no_pkwt2' => $this->input->post('no_pkwt2'),
			'awal_kontrak_pkwt2' => date('Y-m-d', strtotime($this->input->post('awal_kontrak_pkwt2'))),
			'akhir_kontrak_pkwt2' => date('Y-m-d', strtotime($this->input->post('akhir_kontrak_pkwt2'))),
			'lama_kontrak2' => $this->input->post('lama_kontrak2'),
			'no_pkwt3' => $this->input->post('no_pkwt3'),
			'awal_kontrak_pkwt3' => date('Y-m-d', strtotime($this->input->post('awal_kontrak_pkwt3'))),
			'akhir_kontrak_pkwt3' => date('Y-m-d', strtotime($this->input->post('akhir_kontrak_pkwt3'))),
			'lama_kontrak3' => $this->input->post('lama_kontrak3'),
			'id_card_status' => $this->input->post('id_card_status'),
			'no_id_card' => $this->input->post('no_id_card'),
			'tanggal_sp1' => date('Y-m-d', strtotime($this->input->post('tanggal_sp1'))),
			'alasan_sp1' => $this->input->post('alasan_sp1'),
			'tanggal_sp2' => date('Y-m-d', strtotime($this->input->post('tanggal_sp2'))),
			'alasan_sp2' => $this->input->post('alasan_sp2'),
			'tanggal_sp3' => date('Y-m-d', strtotime($this->input->post('tanggal_sp3'))),
			'alasan_sp3' => $this->input->post('alasan_sp3'),
			'status_phk' => $this->input->post('status_phk'),
			'mutasi_dari' => $this->input->post('mutasi_dari'),
			'mutasi_ke' => $this->input->post('mutasi_ke'),
			'tanggal_mutasi' => date('Y-m-d', strtotime($this->input->post('tanggal_mutasi'))),
			'tanggal_berhenti' => date('Y-m-d', strtotime($this->input->post('tanggal_berhenti'))),
			'alasan_berhenti' => $this->input->post('alasan_berhenti'),
			'keterangan' => $this->input->post('keterangan'),
			'gaji_pokok' => $this->input->post('gaji_pokok'),
			'allowance' => $this->input->post('allowance'),
			'uang_kehadiran' => $this->input->post('uang_kehadiran'),
			'overtime' => $this->input->post('overtime'),
			'tunjangan_jabatan' => $this->input->post('tunjangan_jabatan'),
			'tunjangan_transport' => $this->input->post('tunjangan_transport'),
			'tunjangan_makan' => $this->input->post('tunjangan_makan'),
			'tunjangan_pulsa' => $this->input->post('tunjangan_pulsa'),
			'tunjangan_shift' => $this->input->post('tunjangan_shift'),
			'komisi' => $this->input->post('komisi'),
			'incentive' => $this->input->post('incentive'),
			'bonus' => $this->input->post('bonus'),
			'adjustment' => $this->input->post('adjustment'),
			'lain' => $this->input->post('lain'),                
		);
		$this->mkaryawan->fJsSimpanDataKaryawan($data123);
        redirect('home/listdata');
	}
		
    public function editdata() {
      /*if (!$this->session->userdata('username')) {
            redirect('login');
            return;
        }
       $data['list'] = $this->mvendor->dasboardallvendor();*/
       $id=$this->uri->segment(3);
       $this->load->helper('url');
       //$this->data['sidebardaftar']="active";
       $this->data['query'] = $this->mkaryawan->getdatakaryawan($id);
       $this->data['queryprovinsi'] = $this->mkaryawan->fgetallprovinsi();
       $this->data['querykota'] = $this->mkaryawan->fgetallkota();
       $this->data['querycustomer'] = $this->mkaryawan->fgetallcustomer();
       $rowdatakaryawan = $this->data['query'];
       $id_kota = $rowdatakaryawan[0]->id_cabang;
       $this->data['provinsi_edit'] = $this->mkaryawan->get_provinsi($id_kota);
       $this->load->view('veditdata',$this->data);

       
        //$this->load->view('vchart');
    }     
  	public function fPUpdateData(){

  		if($this->input->post('customer') == '')
	  		$id_customer = $this->session->userdata('id_customer');
	  	else
	  		$id_customer = $this->input->post('customer');
	  		
  		if($this->input->post('cabang') == '')
	  		$id_cabang = $this->session->userdata('id_kota');
	  	else
	  		$id_cabang = $this->input->post('cabang');
	  		
        $data123 = array(
			'id' => $this->input->post('id'),
			'username_creator' => $this->session->userdata('username'),
			'tanggal_update' => date('Y-m-d', time()),
			'id_customer' => $id_customer,
			'nik_customer' => $this->input->post('nik_customer'),
			'nik_sjs' => $this->input->post('nik_sjs'),
			'nama_kar' => $this->input->post('nama_kar'),
			'jabatan' => $this->input->post('jabatan'),
			'departement' => $this->input->post('departement'),
			'id_cabang' => $id_cabang,
			'status_kar' => $this->input->post('status_kar'),			
			'joint_awal' => date('Y-m-d', strtotime($this->input->post('joint_awal'))),
			'total_cuti' => $this->input->post('total_cuti'),
			'cuti_dipakai' => $this->input->post('cuti_dipakai'),
			'sisa_cuti' => $this->input->post('sisa_cuti'),
			'bank' => $this->input->post('bank'),
			'no_rekening' => $this->input->post('no_rekening'),
			'nama_rek' => $this->input->post('nama_rek'),
			'jenis_kelamin' => $this->input->post('jenis_kelamin'),
			'tempat_lahir' => $this->input->post('tempat_lahir'),
			'tanggal_lahir' => date('Y-m-d', strtotime($this->input->post('tanggal_lahir'))),
			'agama' => $this->input->post('agama'),
			'alamat_ktp' => $this->input->post('alamat_ktp'),
			'rt' => $this->input->post('rt'),
			'rw' => $this->input->post('rw'),
			'kode_pos' => $this->input->post('kode_pos'),
			'kecamatan' => $this->input->post('kecamatan'),
			'desa' => $this->input->post('desa'),
			'kabupaten' => $this->input->post('kabupaten'),
			'alamat_tinggal' => $this->input->post('alamat_tinggal'),
			'rt_tinggal' => $this->input->post('rt_tinggal'),
			'rw_tinggal' => $this->input->post('rw_tinggal'),
			'kode_pos_tinggal' => $this->input->post('kode_pos_tinggal'),
			'kecamatan_tinggal' => $this->input->post('kecamatan_tinggal'),
			'desa_tinggal' => $this->input->post('desa_tinggal'),
			'kabupaten_tinggal' => $this->input->post('kabupaten_tinggal'),
			'tel_rumah' => $this->input->post('tel_rumah'),
			'tel_hp' => $this->input->post('tel_hp'),
			'tel_hp2' => $this->input->post('tel_hp2'),
			'tel_keluarga' => $this->input->post('tel_keluarga'),
			'hub_keluarga' => $this->input->post('hub_keluarga'),
			'nama_keluarga' => $this->input->post('nama_keluarga'),
			'pendidikan' => $this->input->post('pendidikan'),
			'nama_sekolah' => $this->input->post('nama_sekolah'),
			'jurusan' => $this->input->post('jurusan'),
			'jenis_identitas' => $this->input->post('jenis_identitas'),
			'no_identitas' => $this->input->post('no_identitas'),
			'no_npwp' => $this->input->post('no_npwp'),
			'no_jamsostek' => $this->input->post('no_jamsostek'),
			'bpjs' => $this->input->post('bpjs'),
			'nama_asuransi' => $this->input->post('nama_asuransi'),
			'no_asuransi' => $this->input->post('no_asuransi'),
			'kode_jamsostek' => $this->input->post('kode_jamsostek'),
			'ppk_jamsostek' => $this->input->post('ppk_jamsostek'),
			'tipe_jaminan' => $this->input->post('tipe_jaminan'),
			'no_jaminan' => $this->input->post('no_jaminan'),
			'no_bpkb' => $this->input->post('no_bpkb'),
			'penyimpanan_jaminan' => $this->input->post('penyimpanan_jaminan'),
			'nama_ibu' => $this->input->post('nama_ibu'),
			'status_perkawinan' => $this->input->post('status_perkawinan'),
			'no_kk' => $this->input->post('no_kk'),
			'nama_suami_istri' => $this->input->post('nama_suami_istri'),
			'no_ktp_nik_pasangan' => $this->input->post('no_ktp_nik_pasangan'),
			'jenis_kelamin_si' => $this->input->post('jenis_kelamin_si'),
			'tempat_lahir_si' => $this->input->post('tempat_lahir_si'),
			'tgl_lahir_si' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_si'))),
			'nama_anak1' => $this->input->post('nama_anak1'),
			'jenis_kelamin_anak1' => $this->input->post('jenis_kelamin_anak1'),
			'tempat_lahir_anak1' => $this->input->post('tempat_lahir_anak1'),
			'tgl_lahir_anak1' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_anak1'))),
			'nama_anak2' => $this->input->post('nama_anak2'),
			'jenis_kelamin_anak2' => $this->input->post('jenis_kelamin_anak2'),
			'tempat_lahir_anak2' => $this->input->post('tempat_lahir_anak2'),
			'tgl_lahir_anak2' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_anak2'))),
			'nama_anak3' => $this->input->post('nama_anak3'),
			'jenis_kelamin_anak3' => $this->input->post('jenis_kelamin_anak3'),
			'tempat_lahir_anak3' => $this->input->post('tempat_lahir_anak3'),
			'tgl_lahir_anak3' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_anak3'))),
			'nama_anak4' => $this->input->post('nama_anak4'),
			'jenis_kelamin_anak4' => $this->input->post('jenis_kelamin_anak4'),
			'tempat_lahir_anak4' => $this->input->post('tempat_lahir_anak4'),
			'tgl_lahir_anak4' => date('Y-m-d', strtotime($this->input->post('tgl_lahir_anak4'))),
			'no_pkwt1' => $this->input->post('no_pkwt1'),
			'awal_kontrak_pkwt1' => date('Y-m-d', strtotime($this->input->post('awal_kontrak_pkwt1'))),
			'akhir_kontrak_pkwt1' => date('Y-m-d', strtotime($this->input->post('akhir_kontrak_pkwt1'))),
			'lama_kontrak1' => $this->input->post('lama_kontrak1'),
			'no_pkwt2' => $this->input->post('no_pkwt2'),
			'awal_kontrak_pkwt2' => date('Y-m-d', strtotime($this->input->post('awal_kontrak_pkwt2'))),
			'akhir_kontrak_pkwt2' => date('Y-m-d', strtotime($this->input->post('akhir_kontrak_pkwt2'))),
			'lama_kontrak2' => $this->input->post('lama_kontrak2'),
			'no_pkwt3' => $this->input->post('no_pkwt3'),
			'awal_kontrak_pkwt3' => date('Y-m-d', strtotime($this->input->post('awal_kontrak_pkwt3'))),
			'akhir_kontrak_pkwt3' => date('Y-m-d', strtotime($this->input->post('akhir_kontrak_pkwt3'))),
			'lama_kontrak3' => $this->input->post('lama_kontrak3'),
			'id_card_status' => $this->input->post('id_card_status'),
			'no_id_card' => $this->input->post('no_id_card'),
			'tanggal_sp1' => date('Y-m-d', strtotime($this->input->post('tanggal_sp1'))),
			'alasan_sp1' => $this->input->post('alasan_sp1'),
			'tanggal_sp2' => date('Y-m-d', strtotime($this->input->post('tanggal_sp2'))),
			'alasan_sp2' => $this->input->post('alasan_sp2'),
			'tanggal_sp3' => date('Y-m-d', strtotime($this->input->post('tanggal_sp3'))),
			'alasan_sp3' => $this->input->post('alasan_sp3'),
			'status_phk' => $this->input->post('status_phk'),
			'mutasi_dari' => $this->input->post('mutasi_dari'),
			'mutasi_ke' => $this->input->post('mutasi_ke'),
			'tanggal_mutasi' => date('Y-m-d', strtotime($this->input->post('tanggal_mutasi'))),
			'tanggal_berhenti' => date('Y-m-d', strtotime($this->input->post('tanggal_berhenti'))),
			'alasan_berhenti' => $this->input->post('alasan_berhenti'),
			'keterangan' => $this->input->post('keterangan'),
			'gaji_pokok' => $this->input->post('gaji_pokok'),
			'allowance' => $this->input->post('allowance'),
			'uang_kehadiran' => $this->input->post('uang_kehadiran'),
			'overtime' => $this->input->post('overtime'),
			'tunjangan_jabatan' => $this->input->post('tunjangan_jabatan'),
			'tunjangan_transport' => $this->input->post('tunjangan_transport'),
			'tunjangan_makan' => $this->input->post('tunjangan_makan'),
			'tunjangan_pulsa' => $this->input->post('tunjangan_pulsa'),
			'tunjangan_shift' => $this->input->post('tunjangan_shift'),
			'komisi' => $this->input->post('komisi'),
			'incentive' => $this->input->post('incentive'),
			'bonus' => $this->input->post('bonus'),
			'adjustment' => $this->input->post('adjustment'),
			'lain' => $this->input->post('lain'),         
		);
		$this->mkaryawan->fJsUpdateDataKaryawan($data123);		
		redirect('home/listdata');  		
  	}
	public function hapuskaryawan()
	{
		$id = $this->input->post('id');
		$this->mkaryawan->hapuskaryawan($id);
		return true;
	}
	public function hapuscustomer()
	{
		$id = $this->input->post('id');
		$this->mkaryawan->hapuscustomer($id);
		return true;
	}
	public function hapususer()
	{
		$id = $this->input->post('id');
		$this->mkaryawan->hapususer($id);
		return true;
	}
	public function gantipenanggungjawab()
	{
        $id=explode(',',$this->input->post('id'));
        $penanggungjawab = $this->input->post('penanggungjawab');
        $this->mkaryawan->mgantipenanggungjawab($id,$penanggungjawab);
		return true;
	}
}
